#include <iostream>
#include <string>

using namespace std;

class Solution {
public:
    int StrToInt(string str) {
        int sign = 1;
        auto it = str.begin();
        if (*it == '-')
        {
            sign = -1;
            it++;
        }
        else if (*it == '+')
        {
            it++;
        }

        auto it0 = it;

        while (it < str.end())
        {
            if (*it > '9' || *it < '0')
            {
                if (*it != '+' || *it != '-')
                {
                    return 0;
                }
                else
                    break;
            }
            it++;
        }

        int ret = 0;
        int n = 1;
        auto it1 = --it;
        while (it1 >= it0)
        {
            ret += (*it1 - 48) * n;
            n *= 10;
            it1--;
        }
        return sign * ret;
    }
};

int main()
{
    string s0("+2147483647");

    cout << Solution().StrToInt(s0) << endl;



    return 0;
}